package cn.jinjimi.app.custom.ui.view;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;

import cn.jinjimi.app.R;

/**
 * Created by Roy
 * Date: 16/6/13
 */
public class CustomPhoneDelWindow extends PopupWindow implements View.OnClickListener {
    private onActionClickListener listener;

    public CustomPhoneDelWindow(Context context, onActionClickListener listener) {
        this.listener = listener;
        View view = View.inflate(context, R.layout.window_custom_phone_del_layout, null);
        setContentView(view);

        initListener(view);

        setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
        setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        setAnimationStyle(R.style.pop_right_in_out_anim_style);
        setOutsideTouchable(true);
        setFocusable(true);
        setTouchable(true);
    }

    private void initListener(View view) {
        view.findViewById(R.id.btn_del).setOnClickListener(this);
        view.findViewById(R.id.more_menu_bg).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_del:
                if (listener != null)
                    listener.onDelClick();
                dismiss();
                break;
            case R.id.more_menu_bg:
                dismiss();
                break;
        }
    }

    public interface onActionClickListener {
        void onDelClick();
    }

}
